﻿{extends file="admin/layout.tpl"}

{block name="title"}##NA_PESONAL_INFO##{/block}

{block name="script"}
	$(document).ready(function () {
	
	$('table#accounts td a.delete').click(function()
    {
        if (confirm("Bạn muốn xóa thông tin ứng tuyển này?"))
        {
            var id = $(this).parent().parent().attr('id');
            var data = 'id=' + id ;
            var url = '?action=delete&' + data;
			window.location.href = url;
        }
    });

	
	
	});
	
	function changeType(){
		var select = document.getElementById('candidature_type');
		
		var index = select.selectedIndex;
		var option = select[index];
		
		var url = '?type=' + option.value;
		window.location.href = url;
	}
	
{/block}

{block name="name"}
	Quản lý ứng tuyển
{/block}

{block name="content"}
	<div class="message {$type_message|default:'error'}" style="display:{$is_display|default:'none'};">{$message|default:''}</div>
    <div class="clear">
	</div>
	
	<div class="box round first center">
		<h2>Danh sách ứng tuyển</h2>
		
		<div>
			<label>Loại ứng tuyển</label>
			<select id="candidature_type" name="candidature_type" onchange="changeType()">
				<option value="0">Tất cả</option>
				{foreach $candidature_types as $i}
					<option value="{$i.Ma}" {if $candidature_type == $i.Ma}selected{/if}}> {$i.NoiDung} </option>
				{/foreach}
				
			</select>
		</div>
		
		<table class="data display datatable" id="candidatures" name="candidatures">
            <thead>
                <tr>
					<td bgcolor="#FFFFFF"><strong>
                        Tên tài khoản
                    </strong></td>
                    <td bgcolor="#FFFFFF"><strong>
                        Tên người dùng
                    </strong></td>
                    <td bgcolor="#FFFFFF"><strong>
                        Nội dung ứng tuyển
                    </strong></td>
                    <td bgcolor="#FFFFFF"><strong>
                        Thời điểm ứng tuyển
                    </strong></td>
                    <td bgcolor="#FFFFFF"><strong>
                        Tình trạng
                    </strong></td>
                    <td bgcolor="#FFFFFF"><strong>
                        Xử lý
                    </strong></td>
                    <td bgcolor="#FFFFFF"><strong>
                        Xóa
                    </strong></td>
                </tr>
            </thead>
            
            <tbody>
            {foreach $candidates|default:array() as $i}
                <tr id="{$i.MaUser}"> 
					<td>
                                            <a target="_blank" href="profile.php?userID={$i.MaUser}">{$i.Email}</a>
                    </td>
                    <td>
						{$i.HoTen}
					</td>
                    <td>
                        {$i.NoiDungUngTuyen}
                    </td>
                    <td>
                        {$i.ThoiDiemUngTuyen}
                    </td>
                    <td>
                        <span>
                        {if $i.TinhTrang==0}Đang xử lý
                            {/if}
                            {if $i.TinhTrang==-1}Đã từ chối
                            {/if}
                            {if $i.TinhTrang==1}Đã duyệt
                            {/if}
                            </span>
                    </td>
                    <td>
                        {if $i.TinhTrang==0}
                        <a href="?id={$i.Ma}&action=accept{if isset($candidature_type)}&type={$candidature_type}{/if}&page={$page_current}" class="accept"><img src="{$wwwUrl|default:''}img/check.png"/> Duyệt</a> <br>
                        <a href="?id={$i.Ma}&action=refuse{if isset($candidature_type)}&type={$candidature_type}{/if}&page={$page_current}" class="refuse"> <img src="{$wwwUrl|default:''}img/block.png"/> Từ chối</a> 
                        {/if}
                          
                    </td>
                    
					<td align="center"><a href="" class="delete">Xóa</a></td>
				</tr>            
                    
               
            {/foreach}
            </tbody> 
        </table>
            <ul id="pagination-flickr">
		{if $page_current|default:1 == 1}
			<li class="previous-off">« Previous</li>
		{else}
			<li class="previous"><a href="?page={$page_current - 1}&type={$candidature_type}">« Previous</a></li>
		{/if}
		
		{if $page_current <= 3}
			{for $i = 1 to $page_count max=5}
				{if $i == $page_current}
					<li class="active">{$i}</li>
				{else}
					<li><a href="?page={$i}&type={$candidature_type}">{$i}</a></li>
				{/if}
			{/for}	
		{else}
			{for $i = -2 to 2}
				{if $page_current + $i <= $page_count}
					{if $page_current + $i == $page_current}
						<li class="active">{$page_current}</li>
					{else}
						<li><a href="?page={$page_current + $i}&type={$candidature_type}">{$page_current + $i}</a></li>
					{/if}
				{/if}
			{/for}
		{/if}
		
		{if $page_current == $page_count}
			<li class="next-off">Next »</li>
		{else}
			<li class="next"><a href="?page={$page_current + 1}&type={$candidature_type}">Next »</a></li>
		{/if}
	</ul> 
	</div>
	<div class="clear">
        </div>	
	
	
	
{/block}